package com.tantou.java.structandalgorithm.sort;

import java.util.Arrays;

/**
 * 冒泡排序
 */
public class BubbleSortTest {

    public static void main(String[] args) {
        int[] nums = {2,5,6,4,3,7};
        nums = sort(nums);
        System.out.println(Arrays.toString(nums));
    }

    public static int[] sort(int[] nums) {

        if (nums.length < 1) {
            return nums;
        }
        for (int i = 0; i < nums.length - 1; i++) {
            for (int j = 0; j < nums.length - 1 - i; j++) {
                if (nums[j] > nums[j + 1]) {
                    int tmp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = tmp;
                }
            }
        }
        return nums;
    }

}
